package com.example.laundry.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/api/**")  // 更精确的路径匹配
                .allowedOrigins("http://localhost:8081", "http://192.168.8.12:8081")
                .allowedMethods("*")
                .allowedHeaders("Authorization", "Content-Type")
                .exposedHeaders("X-Custom-Header")
                .allowCredentials(true)
                .maxAge(3600);
    }
}